/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.hotel.test.model.impl;

import com.hotel.test.model.Local;
import com.hotel.test.model.LocalModel;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.DateUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.util.PortalUtil;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import java.io.Serializable;

import java.sql.Types;

import java.util.Date;

/**
 * The base model implementation for the Local service. Represents a row in the &quot;HT_Local&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.hotel.test.model.LocalModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link LocalImpl}.
 * </p>
 *
 * @author Vien-IT
 * @see LocalImpl
 * @see com.hotel.test.model.Local
 * @see com.hotel.test.model.LocalModel
 * @generated
 */
public class LocalModelImpl extends BaseModelImpl<Local> implements LocalModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a local model instance should use the {@link com.hotel.test.model.Local} interface instead.
	 */
	public static final String TABLE_NAME = "HT_Local";
	public static final Object[][] TABLE_COLUMNS = {
			{ "localId", Types.BIGINT },
			{ "userId", Types.BIGINT },
			{ "userName", Types.VARCHAR },
			{ "createDate", Types.TIMESTAMP },
			{ "modifiedDate", Types.TIMESTAMP },
			{ "localName", Types.VARCHAR },
			{ "introduce", Types.VARCHAR },
			{ "image", Types.VARCHAR }
		};
	public static final String TABLE_SQL_CREATE = "create table HT_Local (localId LONG not null primary key,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,localName VARCHAR(75) null,introduce VARCHAR(75) null,image VARCHAR(75) null)";
	public static final String TABLE_SQL_DROP = "drop table HT_Local";
	public static final String ORDER_BY_JPQL = " ORDER BY local.modifiedDate ASC";
	public static final String ORDER_BY_SQL = " ORDER BY HT_Local.modifiedDate ASC";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.hotel.test.model.Local"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.hotel.test.model.Local"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.column.bitmask.enabled.com.hotel.test.model.Local"),
			true);
	public static long LOCALNAME_COLUMN_BITMASK = 1L;
	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.hotel.test.model.Local"));

	public LocalModelImpl() {
	}

	public long getPrimaryKey() {
		return _localId;
	}

	public void setPrimaryKey(long primaryKey) {
		setLocalId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_localId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	public Class<?> getModelClass() {
		return Local.class;
	}

	public String getModelClassName() {
		return Local.class.getName();
	}

	public long getLocalId() {
		return _localId;
	}

	public void setLocalId(long localId) {
		_localId = localId;
	}

	public long getUserId() {
		return _userId;
	}

	public void setUserId(long userId) {
		_userId = userId;
	}

	public String getUserUuid() throws SystemException {
		return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
	}

	public void setUserUuid(String userUuid) {
		_userUuid = userUuid;
	}

	public String getUserName() {
		if (_userName == null) {
			return StringPool.BLANK;
		}
		else {
			return _userName;
		}
	}

	public void setUserName(String userName) {
		_userName = userName;
	}

	public Date getCreateDate() {
		return _createDate;
	}

	public void setCreateDate(Date createDate) {
		_createDate = createDate;
	}

	public Date getModifiedDate() {
		return _modifiedDate;
	}

	public void setModifiedDate(Date modifiedDate) {
		_columnBitmask = -1L;

		_modifiedDate = modifiedDate;
	}

	public String getLocalName() {
		if (_localName == null) {
			return StringPool.BLANK;
		}
		else {
			return _localName;
		}
	}

	public void setLocalName(String localName) {
		_columnBitmask |= LOCALNAME_COLUMN_BITMASK;

		if (_originalLocalName == null) {
			_originalLocalName = _localName;
		}

		_localName = localName;
	}

	public String getOriginalLocalName() {
		return GetterUtil.getString(_originalLocalName);
	}

	public String getIntroduce() {
		if (_introduce == null) {
			return StringPool.BLANK;
		}
		else {
			return _introduce;
		}
	}

	public void setIntroduce(String introduce) {
		_introduce = introduce;
	}

	public String getImage() {
		if (_image == null) {
			return StringPool.BLANK;
		}
		else {
			return _image;
		}
	}

	public void setImage(String image) {
		_image = image;
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

	@Override
	public Local toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (Local)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		if (_expandoBridge == null) {
			_expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
					Local.class.getName(), getPrimaryKey());
		}

		return _expandoBridge;
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		getExpandoBridge().setAttributes(serviceContext);
	}

	@Override
	public Object clone() {
		LocalImpl localImpl = new LocalImpl();

		localImpl.setLocalId(getLocalId());
		localImpl.setUserId(getUserId());
		localImpl.setUserName(getUserName());
		localImpl.setCreateDate(getCreateDate());
		localImpl.setModifiedDate(getModifiedDate());
		localImpl.setLocalName(getLocalName());
		localImpl.setIntroduce(getIntroduce());
		localImpl.setImage(getImage());

		localImpl.resetOriginalValues();

		return localImpl;
	}

	public int compareTo(Local local) {
		int value = 0;

		value = DateUtil.compareTo(getModifiedDate(), local.getModifiedDate());

		if (value != 0) {
			return value;
		}

		return 0;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		Local local = null;

		try {
			local = (Local)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = local.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
		LocalModelImpl localModelImpl = this;

		localModelImpl._originalLocalName = localModelImpl._localName;

		localModelImpl._columnBitmask = 0;
	}

	@Override
	public CacheModel<Local> toCacheModel() {
		LocalCacheModel localCacheModel = new LocalCacheModel();

		localCacheModel.localId = getLocalId();

		localCacheModel.userId = getUserId();

		localCacheModel.userName = getUserName();

		String userName = localCacheModel.userName;

		if ((userName != null) && (userName.length() == 0)) {
			localCacheModel.userName = null;
		}

		Date createDate = getCreateDate();

		if (createDate != null) {
			localCacheModel.createDate = createDate.getTime();
		}
		else {
			localCacheModel.createDate = Long.MIN_VALUE;
		}

		Date modifiedDate = getModifiedDate();

		if (modifiedDate != null) {
			localCacheModel.modifiedDate = modifiedDate.getTime();
		}
		else {
			localCacheModel.modifiedDate = Long.MIN_VALUE;
		}

		localCacheModel.localName = getLocalName();

		String localName = localCacheModel.localName;

		if ((localName != null) && (localName.length() == 0)) {
			localCacheModel.localName = null;
		}

		localCacheModel.introduce = getIntroduce();

		String introduce = localCacheModel.introduce;

		if ((introduce != null) && (introduce.length() == 0)) {
			localCacheModel.introduce = null;
		}

		localCacheModel.image = getImage();

		String image = localCacheModel.image;

		if ((image != null) && (image.length() == 0)) {
			localCacheModel.image = null;
		}

		return localCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(17);

		sb.append("{localId=");
		sb.append(getLocalId());
		sb.append(", userId=");
		sb.append(getUserId());
		sb.append(", userName=");
		sb.append(getUserName());
		sb.append(", createDate=");
		sb.append(getCreateDate());
		sb.append(", modifiedDate=");
		sb.append(getModifiedDate());
		sb.append(", localName=");
		sb.append(getLocalName());
		sb.append(", introduce=");
		sb.append(getIntroduce());
		sb.append(", image=");
		sb.append(getImage());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(28);

		sb.append("<model><model-name>");
		sb.append("com.hotel.test.model.Local");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>localId</column-name><column-value><![CDATA[");
		sb.append(getLocalId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>userId</column-name><column-value><![CDATA[");
		sb.append(getUserId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>userName</column-name><column-value><![CDATA[");
		sb.append(getUserName());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>createDate</column-name><column-value><![CDATA[");
		sb.append(getCreateDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
		sb.append(getModifiedDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>localName</column-name><column-value><![CDATA[");
		sb.append(getLocalName());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>introduce</column-name><column-value><![CDATA[");
		sb.append(getIntroduce());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>image</column-name><column-value><![CDATA[");
		sb.append(getImage());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = Local.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			Local.class
		};
	private long _localId;
	private long _userId;
	private String _userUuid;
	private String _userName;
	private Date _createDate;
	private Date _modifiedDate;
	private String _localName;
	private String _originalLocalName;
	private String _introduce;
	private String _image;
	private transient ExpandoBridge _expandoBridge;
	private long _columnBitmask;
	private Local _escapedModelProxy;
}